/*
 * @Description: 首页上下文
 * @Author: seadon
 * @LastEditors: seadon
 * @Date: 2021-07-21 10:38:22
 * @LastEditTime: 2021-07-21 10:42:58
 */
import { InjectionKey } from 'vue'
import { createContext, useContext } from '@/hooks/useContext'
import Mitt from '@/utils/tiny-mitt'

export interface HomeContextProps {
	homeEmitter: Mitt
}

const key: InjectionKey<HomeContextProps> = Symbol()

export function createHomeContext(context: HomeContextProps) {
	return createContext<HomeContextProps>(context, key, {
		readonly: false,
		native: true,
	})
}

export function useHomeContext() {
	return useContext<HomeContextProps>(key)
}
